package cn.edu.scau.cmi.lvmingyan.singleton;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class MyController implements Initializable {

	@FXML
	private Button create;
	@FXML
	private TextField name;
	@FXML
	private Label result;
	@FXML
	private Label detail;
	
	@Override
	public void initialize(URL location, ResourceBundle resources) {
	}
	
	public void onClick(ActionEvent event) {
		String text = name.getText();
    	if(text == null) {
    		result.setText("No name to create!");
    		return ;
    	}
    	if(Chairman.createChairman(text)) {
    		result.setText("The man is successfully created!");
    	}
    	else {
    		result.setText("The man is failed to created!");
    	}
    	Chairman chairman = Chairman.getChairman();
    	String name = chairman.getName();
        detail.setText("\n"+chairman.getName() + chairman.toString());
	}

}
